$(function(){
    $("select[name=server]").change(function(){
       //alert($(this).val());
        $("#character-loader").show();
        $.ajax({
          type: "POST",
          url: "quay-so/get_character",
          data: {server: $(this).val()}
        }).done(function(character) {
              if(character==""){
                    $("select[name=character]").html('<option value="">Chưa tạo nhân vật</option>');
              } else {
                $("select[name=character]").html('<option value="'+character+'">'+character+'</option>');
              }
              $("#character-loader").hide();
        });
    });
    
    $("input[name=clear]").click(function(){
        //clear input
        $("form input[type=text]").each(function(){
            $(this).val("");
        });
        
        //clear select
        $("form select").each(function(){
            $(this).val("");
        });
    });
});